﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOFrameworks;
using FAQFrameworks;
using FooFun.DataElements.Dtos;

namespace FooFun.Web.Controls
{
    public class SelfAnswerControl : DataElementControl
    {
        public override IDataElement DataElement
        {
            get
            {
                return base.DataElement;
            }
            set
            {
                base.DataElement = value;
                if (base.DataElement.IsEmpty)
                {
                    if (base.DataElement.Parent.Parent["@Status"].Equals("Sealed") || FAQContext.Current.User.AccountId == Guid.Empty)
                    {
                        this.Controls.Clear();
                    }

                    EventManager eventManager = new EventManager();

                    IDataElement eventDE = eventManager.GetElement(
                        base.DataElement.Parent.Parent["@EventId"]);

                    if (eventDE["AccountId"].Equals
                        (FAQContext.Current.User.AccountId))
                    {
                        this.Controls.Clear();
                    }
                }
            }
        }
    }
}
